home *** CD-ROM | disk | FTP | other *** search
/ PC Users 8 / Cd Pc Users extra 8.iso / prog / inst / firstimp / vcimpres.z / chdraw.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-09-11  |  14.1 KB  |  385 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H00C0C0C0&
  5.    Caption         =   "First Impression Draw to hDC Example"
  6.    ClientHeight    =   6570
  7.    ClientLeft      =   2550
  8.    ClientTop       =   1680
  9.    ClientWidth     =   9540
  10.    BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  11.       Name            =   "MS Sans Serif"
  12.       Size            =   8.25
  13.       Charset         =   0
  14.       Weight          =   700
  15.       Underline       =   0   'False
  16.       Italic          =   0   'False
  17.       Strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H80000008&
  20.    Height          =   6975
  21.    Icon            =   "chdraw.frx":0000
  22.    Left            =   2490
  23.    LinkTopic       =   "Form1"
  24.    ScaleHeight     =   6570
  25.    ScaleWidth      =   9540
  26.    Top             =   1335
  27.    Width           =   9660
  28.    Begin Threed.SSPanel pnlControls 
  29.       Height          =   6435
  30.       Left            =   6240
  31.       TabIndex        =   0
  32.       Top             =   60
  33.       Width           =   3195
  34.       _Version        =   65536
  35.       _ExtentX        =   5636
  36.       _ExtentY        =   11351
  37.       _StockProps     =   15
  38.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  39.          Name            =   "MS Sans Serif"
  40.          Size            =   8.25
  41.          Charset         =   0
  42.          Weight          =   700
  43.          Underline       =   0   'False
  44.          Italic          =   0   'False
  45.          Strikethrough   =   0   'False
  46.       EndProperty
  47.       BevelOuter      =   0
  48.       BevelInner      =   1
  49.       Begin VB.PictureBox Picture1 
  50.          Appearance      =   0  'Flat
  51.          AutoRedraw      =   -1  'True
  52.          BackColor       =   &H80000005&
  53.          ClipControls    =   0   'False
  54.          ForeColor       =   &H80000008&
  55.          Height          =   3195
  56.          Left            =   120
  57.          ScaleHeight     =   3165
  58.          ScaleWidth      =   2925
  59.          TabIndex        =   10
  60.          Top             =   120
  61.          Width           =   2955
  62.       End
  63.       Begin VB.Frame Frame1 
  64.          Caption         =   " Draw To: "
  65.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  66.             Name            =   "MS Sans Serif"
  67.             Size            =   8.25
  68.             Charset         =   0
  69.             Weight          =   400
  70.             Underline       =   0   'False
  71.             Italic          =   0   'False
  72.             Strikethrough   =   0   'False
  73.          EndProperty
  74.          Height          =   795
  75.          Index           =   2
  76.          Left            =   480
  77.          TabIndex        =   7
  78.          Top             =   5400
  79.          Width           =   2235
  80.          Begin VB.CommandButton cmdPrinter 
  81.             Caption         =   "Printer"
  82.             BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  83.                Name            =   "MS Sans Serif"
  84.                Size            =   8.25
  85.                Charset         =   0
  86.                Weight          =   400
  87.                Underline       =   0   'False
  88.                Italic          =   0   'False
  89.                Strikethrough   =   0   'False
  90.             EndProperty
  91.             Height          =   375
  92.             Left            =   1200
  93.             TabIndex        =   9
  94.             Top             =   300
  95.             Width           =   915
  96.          End
  97.          Begin VB.CommandButton cmdPicture 
  98.             Caption         =   "Picture"
  99.             BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  100.                Name            =   "MS Sans Serif"
  101.                Size            =   8.25
  102.                Charset         =   0
  103.                Weight          =   400
  104.                Underline       =   0   'False
  105.                Italic          =   0   'False
  106.                Strikethrough   =   0   'False
  107.             EndProperty
  108.             Height          =   375
  109.             Left            =   180
  110.             TabIndex        =   8
  111.             Top             =   300
  112.             Width           =   915
  113.          End
  114.       End
  115.       Begin VB.Frame Frame1 
  116.          Caption         =   " Chart Formatting "
  117.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  118.             Name            =   "MS Sans Serif"
  119.             Size            =   8.25
  120.             Charset         =   0
  121.             Weight          =   400
  122.             Underline       =   0   'False
  123.             Italic          =   0   'False
  124.             Strikethrough   =   0   'False
  125.          EndProperty
  126.          Height          =   795
  127.          Index           =   1
  128.          Left            =   480
  129.          TabIndex        =   4
  130.          Top             =   4500
  131.          Width           =   2235
  132.          Begin Threed.SSCheck chkStretch 
  133.             Height          =   195
  134.             Left            =   240
  135.             TabIndex        =   6
  136.             Top             =   480
  137.             Width           =   1755
  138.             _Version        =   65536
  139.             _ExtentX        =   3096
  140.             _ExtentY        =   344
  141.             _StockProps     =   78
  142.             Caption         =   "Scale To Fit"
  143.             BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  144.                Name            =   "MS Sans Serif"
  145.                Size            =   8.25
  146.                Charset         =   0
  147.                Weight          =   400
  148.                Underline       =   0   'False
  149.                Italic          =   0   'False
  150.                Strikethrough   =   0   'False
  151.             EndProperty
  152.          End
  153.          Begin Threed.SSCheck chkLayout 
  154.             Height          =   255
  155.             Left            =   240
  156.             TabIndex        =   5
  157.             Top             =   240
  158.             Width           =   1755
  159.             _Version        =   65536
  160.             _ExtentX        =   3096
  161.             _ExtentY        =   450
  162.             _StockProps     =   78
  163.             Caption         =   "Layout For New DC"
  164.             BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  165.                Name            =   "MS Sans Serif"
  166.                Size            =   8.25
  167.                Charset         =   0
  168.                Weight          =   400
  169.                Underline       =   0   'False
  170.                Italic          =   0   'False
  171.                Strikethrough   =   0   'False
  172.             EndProperty
  173.          End
  174.       End
  175.       Begin VB.Frame Frame1 
  176.          Caption         =   " Text Metrics "
  177.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  178.             Name            =   "MS Sans Serif"
  179.             Size            =   8.25
  180.             Charset         =   0
  181.             Weight          =   400
  182.             Underline       =   0   'False
  183.             Italic          =   0   'False
  184.             Strikethrough   =   0   'False
  185.          EndProperty
  186.          Height          =   795
  187.          Index           =   0
  188.          Left            =   480
  189.          TabIndex        =   1
  190.          Top             =   3540
  191.          Width           =   2235
  192.          Begin Threed.SSOption optTextMetrics 
  193.             Height          =   195
  194.             Index           =   0
  195.             Left            =   240
  196.             TabIndex        =   3
  197.             Top             =   240
  198.             Width           =   975
  199.             _Version        =   65536
  200.             _ExtentX        =   1720
  201.             _ExtentY        =   344
  202.             _StockProps     =   78
  203.             Caption         =   "Screen"
  204.             BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  205.                Name            =   "MS Sans Serif"
  206.                Size            =   8.25
  207.                Charset         =   0
  208.                Weight          =   400
  209.                Underline       =   0   'False
  210.                Italic          =   0   'False
  211.                Strikethrough   =   0   'False
  212.             EndProperty
  213.          End
  214.          Begin Threed.SSOption optTextMetrics 
  215.             Height          =   195
  216.             Index           =   1
  217.             Left            =   240
  218.             TabIndex        =   2
  219.             Top             =   480
  220.             Width           =   975
  221.             _Version        =   65536
  222.             _ExtentX        =   1720
  223.             _ExtentY        =   344
  224.             _StockProps     =   78
  225.             Caption         =   "Printer"
  226.             BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  227.                Name            =   "MS Sans Serif"
  228.                Size            =   8.25
  229.                Charset         =   0
  230.                Weight          =   400
  231.                Underline       =   0   'False
  232.                Italic          =   0   'False
  233.                Strikethrough   =   0   'False
  234.             EndProperty
  235.             Value           =   -1  'True
  236.          End
  237.       End
  238.    End
  239.    Begin VtChartLib.VtChart VtChart1 
  240.       Height          =   6255
  241.       Left            =   120
  242.       TabIndex        =   11
  243.       Top             =   120
  244.       Width           =   6015
  245.       _ExtentX        =   10610
  246.       _ExtentY        =   11033
  247.       _0              =   $"chdraw.frx":030A
  248.       _1              =   $"chdraw.frx":070F
  249.       _2              =   $"chdraw.frx":0B14
  250.       _3              =   $"chdraw.frx":0F19
  251.       _4              =   $"chdraw.frx":131E
  252.       _5              =   $"chdraw.frx":1723
  253.       _6              =   $"chdraw.frx":1B28
  254.       _7              =   $"chdraw.frx":1F2D
  255.       _8              =   $"chdraw.frx":2333
  256.       _9              =   $"chdraw.frx":2738
  257.       _10             =   $"chdraw.frx":2B3D
  258.       _11             =   $"chdraw.frx":2F42
  259.       _12             =   $"chdraw.frx":3347
  260.       _13             =   $"chdraw.frx":374C
  261.       _14             =   $"chdraw.frx":3B51
  262.       _15             =   $"chdraw.frx":3F56
  263.       _count          =   16
  264.       _ver            =   1
  265.    End
  266. Attribute VB_Name = "Form1"
  267. Attribute VB_Creatable = False
  268. Attribute VB_Exposed = False
  269. Option Explicit
  270. Private Sub chkLayout_Click(Value As Integer)
  271.     ' Scaled is only used if Layout is False
  272.     chkStretch.Enabled = Not (chkLayout.Value)
  273.     chkStretch.Value = 0
  274. End Sub
  275. Private Sub cmdPicture_Click()
  276.    On Error GoTo DrawPictureError
  277.    Dim top%, left%, bottom%, right%
  278.    ' Set the destination to the entire picture box.
  279.    ' Convert from twips (default) to pixels with the
  280.    ' Screen.TwipsPerPixelX property. Note that you can
  281.    ' suffer roundoff error here so you may want to pad
  282.    ' the width and height.
  283.    top = Picture1.ScaleTop / Screen.TwipsPerPixelY
  284.    left = Picture1.ScaleLeft / Screen.TwipsPerPixelX
  285.    bottom = Picture1.ScaleHeight / Screen.TwipsPerPixelY + 2
  286.    right = Picture1.ScaleWidth / Screen.TwipsPerPixelX + 2
  287.    ' Clear out the old image
  288.    Picture1.Cls
  289.    ' Use the check boxes for args so we can readily see how
  290.    ' each possiblity affects the image.
  291.    VtChart1.Draw Picture1.hDC, VtDcTypeDisplay, top, left, _
  292.       bottom, right, chkLayout.Value, chkStretch.Value
  293.       
  294.    Exit Sub
  295. DrawPictureError:
  296.    MsgBox Error
  297. End Sub
  298. Private Sub cmdPrinter_Click()
  299.    On Error GoTo DrawPrinterError
  300.    Dim top%, left%, bottom%, right%
  301.    Dim titleWidth&, titleHeight&
  302.    With Printer
  303.       ' Set the font and position a title on the page.
  304.       ' The chart already has a title -
  305.       ' this title is text drawn directly on the  object.
  306.       .FontSize = 48
  307.       .FontName = "Times New Roman"
  308.       .FontUnderline = True
  309.       titleWidth = .TextWidth("Chart Draw Example")
  310.       titleHeight = .TextHeight("Chart Draw Example")
  311.       
  312.       ' Center the text and move it down off the top margin
  313.       .CurrentX = .ScaleLeft + (.ScaleWidth - titleWidth) / 2
  314.       .CurrentY = 0.3 * titleHeight
  315.       ' Draw the text on the hDC
  316.       Printer.Print "Chart Draw Example"
  317.       
  318.       ' Bounding rect for the chart. Place below Title and conert from twips to pixels.
  319.       top = (.ScaleTop + titleHeight) / .TwipsPerPixelY
  320.       left = .ScaleLeft / .TwipsPerPixelX
  321.       bottom = .ScaleHeight / .TwipsPerPixelY
  322.       right = .ScaleWidth / .TwipsPerPixelX
  323.       
  324.       ' Draw the chart on the  hDC using the option check boxes
  325.       ' as arguments
  326.       VtChart1.Draw Printer.hDC, VtDcTypePrinter, top, left, _
  327.          bottom, right, chkLayout.Value, chkStretch.Value
  328.       
  329.       ' Use these to adjust the line drawings
  330.       '.DrawMode =
  331.       '.DrawStyle =
  332.       '.DrawWidth =
  333.       '.ForeColor =
  334.       
  335.       ' Draw a bounding box
  336.       Printer.Line (.ScaleLeft, .ScaleTop)-(.ScaleWidth, .ScaleTop)
  337.       Printer.Line (.ScaleWidth - 5, .ScaleTop)-(.ScaleWidth - 5, .ScaleHeight)
  338.       Printer.Line (.ScaleWidth - 5, .ScaleHeight - 5)-(.ScaleLeft, .ScaleHeight - 5)
  339.       Printer.Line (.ScaleLeft, .ScaleHeight - 5)-(.ScaleLeft, .ScaleTop)
  340.       
  341.       ' Feed a page and then flush it through the
  342.       .NewPage
  343.       .EndDoc
  344.    End With
  345.    Exit Sub
  346. DrawPrinterError:
  347.    MsgBox Error
  348. End Sub
  349. Private Sub Form_Load()
  350.    ' Put the form in the top left corner
  351.    Form1.left = 0
  352.    Form1.top = 0
  353.    pnlControls.top = 60
  354.    VtChart1.top = 120
  355. End Sub
  356. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  357.    End
  358. End Sub
  359. Private Sub Form_Resize()
  360.    VtChart1.Repaint = False
  361.    If ScaleHeight > 7200 Then
  362.       pnlControls.Height = ScaleHeight - 135
  363.       VtChart1.Height = ScaleHeight - 255
  364.    End If
  365.    If ScaleWidth > 4000 Then
  366.       pnlControls.left = ScaleWidth - pnlControls.Width - 60
  367.       VtChart1.Width = pnlControls.left - 235
  368.    End If
  369.    VtChart1.Repaint = True
  370. End Sub
  371. Private Sub optTextMetrics_Click(Index As Integer, Value As Integer)
  372. '' Screen and printer text metrics are different. If you
  373. '' draw to the screen, you will want to use virtual metrics
  374. '' (defined by the TrueType font). Otherwise use the device
  375. '' type which is optimized for your output device.
  376.    If Value Then
  377.       Select Case Index
  378.          Case 0
  379.             VtChart1.TextLengthType = VtTextLengthTypeVirtual
  380.          Case 1
  381.             VtChart1.TextLengthType = VtTextLengthTypeDevice
  382.       End Select
  383.    End If
  384. End Sub
  385.